#ifndef __GK_H_
#define __GK_H_

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Log types */
#define GK_LOG_NONE 0x00
#define GK_LOG_INFO 0x01
#define GK_LOG_NOTICE 0x02
#define GK_LOG_WARNING 0x04
#define GK_LOG_ERR 0x08
#define GK_LOG_DEBUG 0x10
#define GK_LOG_SUBSCRIBE 0x20
#define GK_LOG_UNSUBSCRIBE 0x40
#define GK_LOG_WEBSOCKETS 0x80
#define GK_LOG_ALL 0xFFFF

#define gattdb_BluFi_Write                     11
#define gattdb_BluFi_Notify                    14

enum BUSSINESS_S{
	BLUFI_IDLE				= 0x00,
	BLUFI_INIT				= 0x01,
	BLUFI_START				= 0x02,
	BLUFI_START_FAIL 		= 0x03,
	BLUFI_START_SUCC 		= 0x04,
	BLUFI_HELLO 			= 0x05,
	BLUFI_HELLO_ING 		= 0x06,
	BLUFI_HELLO_FAIL		= 0x07,
	BLUFI_HELLO_SUCC		= 0x08,
	BLUFI_START_ADV 			= 0x09,
	BLUFI_START_ADV_ING    		= 0x0a,
	BLUFI_START_ADV_SUCC		= 0x0b,
	BLUFI_START_ADV_FAIL		= 0x0c,
	BLUFI_WORKING			= 0x0d,
	BLUFI_STOP_ADV				= 0x0e,
	BLUFI_STOP_ADV_ING			= 0x0f,
	BLUFI_STOP_ADV_FAIL 		= 0x10,
	BLUFI_STOP_ADV_SUCC 		= 0x11,
	BLUFI_STOP  		    = 0x12,
	BLUFI_HEARTBEAT_ING     = 0x13,
	BLUFI_RESET             = 0x14,
};

typedef struct stGk {
	int		buad;
	char	dev[32];
	char    u_mac[6];
	/* 广播数据 */
	char 	bcnBeaconAdvData[31];
	char 	bcnBeaconAdvDataLength;
	/* 扫描响应数据 */
	char    bcnBeaconAdvRspData[31];
	char    bcnBeaconAdvRspDataLength;

} stGk_t;

typedef struct 
{
	void (*hello_rsp_cb)(void);
	int (*beacon_start_cb)(int32_t);
	void (*on_disconnect)(void);
	void (*on_beacon_stop)(int32_t);
	void (*on_data_in)(char* data, int len);
	void (*on_log)(int, const char *);
	void (*on_boot)(uint16_t major, uint16_t minor, uint16_t patch, uint16_t build);
} stGk_evt_t;

int gk_get_fd();
int gk_loop();
int gk_init();
int gk_set_mac(char* mac);
int gk_notify_attribute(char *mac, char *serice_uuid, int slen, char *attr_uuid, int alen, int enable);

int gk_open(char *dev, int buad);
int gk_close();
int gk_advertiser_start();
int gk_advertiser_stop();
int gk_hello();
int gk_heartbeat();
int gk_server_notify(char *data, int len);
int gk_server_notify_battery(char*data,int len);

int gk_register(stGk_evt_t* cbs);
int gk_set_beacon_adv_data(char* data, int length);
int gk_set_beacon_adv_rsp_data(char* data, int length);
#ifdef __cplusplus
}
#endif
#endif

